package cn.wsalix.spring.utils;

import java.util.Date;

import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import cn.wsalix.admin.entity.RequiresRole;
import cn.wsalix.admin.repository.RequiresRoleRepository;
@Component("requiresRolesTraverse")
public class RequiresRolesTraverse implements Traverse<RequiresRoles> {
	@Autowired
	private RequiresRoleRepository requiresRoleRepository;
	@Override
	public void process(RequiresRoles annotation) {
		for(String role:annotation.value()){
			RequiresRole requiresRole=new RequiresRole();
			requiresRole.setCode(role);
			requiresRole.setCreatedDate(new Date());// DateTime.now());
			requiresRole.setCreatedBy(0l);
			requiresRoleRepository.save(requiresRole);
		}			
	}
	
}
